// 导入创建路由
import { createRouter, createWebHashHistory } from 'vue-router';
import Home from '../components/Home.vue'
import About from '../components/About.vue'

import {navData} from '@/untils/nav.js'

const routes = [
    {
        path: '/Home',
        name: 'Home',
        component: Home
    },
    {
        path: '/about',
        name: 'About',
        component: About
    },
]

navData.forEach(element => {
    routes.push({
        path: element.path,
        name: element.name,
        component: () => import ('../' + element.component)
    })
})

//创建路由
const router = createRouter({
    history: createWebHashHistory(),
    routes
})

//导出路由
export default router;